- a look at the results -
Note that depending on your browser and/or your X device the pictures on this page can look different from the original ones.
The show command displays colormap based images and RGB encoded images. The results depend on the display devices.
First let us asume that you have an true color device. To view an
RGB encoded image stored in the (MxNx3) dimensional array image open
a window
( 1)>window(0,\bpp=24);
Here the parameter bpp=24 causes Xi to open a true color device
(3*8 Bits =24 Bits per Pixel).
Let's load the example image
( 2)>image=read_gif("mail1.gif");
and display the image (a (MxNx3) array) with the show commandmv mail1.gif
( 3)>show(image);The result looks like this
Since most people won't have true color devices we now open a window with one to eight bits per pixel (here six)
( 4)>window(0,\bpp=6)Xi initializes the colormap with a default colormap. If you now use the show command with a two dimensional array, each entry of the array will be handled as an index to the colormap. The result will be an image containing only colors from the colormap. You can have a look at the colormap with
( 5)>show(cincarr(1,64));The command loadct allows you to change the colormap. Some predefined functions help you creating the colormap array. Maybe you want a rainbowish colormap
( 6)>colormap=rainbow(62); ( 7)>loadct(colormap);Here colormap is a (Mx3) dimensional array (M=62 colors, three values r, g and b for every point). Important: The colormap entries for the values zero and one can not be redefined. These are the back and the foregroundcolor. As a result the colormap can have only 62 colors and not 2^6=64 colors. To avoid any errors due to this, use the rescale parameter of the show command which automatically rescales your image to the full colormap.
( 7)>show(cincarr(1,64),\rescale); /* uses only 62 colors */
What if you want to display an RGB image on a colormap based window? Take the mailbox from above which already is stored in the array image.
If you only type
( 8)>show(image);than Xi tries to get the best result leaving the colormap unchanged.
Unfortunately this will often be not enough. *ouch* In that case the parameter fitColors instructs the show command to change the colormap. Taking full advantage of all available colors this will lead to better results. Additional a Floyd-Steinberg error diffusion step (dither algorithm) can be enabled with the floyd parameter.
( 8)>show(image, \fitColors, \floyd);This looks better. Fiddle a little with the two parameters to get the best result.
To move or cut out a part of the image use the mouse in the same way as with plots or contours. With the left mouse button you can select the image. Keep the left mouse button pressed to drag the image with the mouse. With the right mouse button you can zoom inside the plot. The default magnifying algorithm just magnifies the pixelsize it doesn't interpolate. Due to this the algorithm is pretty fast. Let's cut out a part of the mailbox.
The other possible magnifying algorithm is the so called bilinear interpolation method. As seen above pixelsize magnifying is the default option. Bilinear interpolation has to be manually set with the linear parameter in the show command.
( 9)>show(image,\fitColors,\linear);If you cut out the mailbox now the result looks like this